package org.example.spring.cycle.controller;

import org.example.spring.cycle.thread.LocalThreadHolder;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @author hzq
 * @date 2022/3/15 10:54
 */
@RestController
@RequestMapping("/request")
public class RequestController {

    @GetMapping("/test")
    public String test(@RequestParam Map<String, Object> map) {
        System.out.println(Thread.currentThread().getName());
        System.out.println(LocalThreadHolder.getT());
        LocalThreadHolder.setT(map);
        System.out.println(LocalThreadHolder.getA());
        LocalThreadHolder.setA(map);
        return "test";
    }

    @GetMapping("/map")
    public Map<String, Object> map(@RequestParam Map<String, Object> map) {
        return map;
    }
}

